<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.Enumeration" %><%--
  Created by IntelliJ IDEA.
  User: 小柒的Java
  Date: 2021/5/7
  Time: 14:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    // 向Tomcat服务器索要当前用户的私人储物柜
    HttpSession session1 = request.getSession();
    // 获取私人储物柜中的信息
    Enumeration<String> attributeNames = session1.getAttributeNames();
    // 遍历
    int count = 0;
    while (attributeNames.hasMoreElements()) {
        String s = attributeNames.nextElement();
        Object attribute = session1.getAttribute(s);
%>
    <table>
        <tr>
            <td>商品名称</td>
            <td>商品数量</td>
        </tr>
        <tr>
            <td><%= s %></td>
        <td>
            <%=attribute%>
        </td>
        </tr>
    </table>

<%

    }
%>

<%--                    <center>
                        <table border="1px" cellspacing="opx">
                            <tr>
                                <td>
                                    商品名称
                                </td>
                            </tr>
                            <tr>
                          <%
                              if (count%2==0){
                          %>
                                <td><%=attribute %></td>
                           <%
                                count++;
                               }
                          %>
                            </tr>
                        </table>
                    </center>
            <center>
                    <table border="1px" cellspacing="opx">
                        <tr>
                        <td>
                           商品单价
                        </td>
                        </tr>
                        <tr>
                            <%
                                if (count%2!=0){
                            %>
                            <td><%=attribute %></td>
                            <%
                                count++;
                                }
                            %>
                        </tr>

                    </table>

            </center>
             <%
                }
            %>--%>


</body>
</html>
